﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace Assignment2_OrderSystem
{
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            // variable which will count the visitors to your site.
            Application["Visits"] = 0;
            // variable which will store the number of online users in your site.
            Application["OnlineUsers"] = 0;
            //it will store a variable which will count of requests done by all users.
            Application["Requests"] = 0;
        }

        protected void Session_Start(object sender, EventArgs e)
        {
            Application["Visits"] = Convert.ToInt32(Application["Visits"]) + 1;
            Application["OnlineUsers"] = Convert.ToInt32(Application["OnlineUsers"]) + 1;
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            Application["Requests"] = Convert.ToInt32(Application["Requests"]) + 1;
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {
            Application["OnlineUsers"] = Convert.ToInt32(Application["OnlineUsers"]) - 1;
        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}